package com.csc.trobbins4.svn;

import java.sql.*;

public class MainDriver {

	/* This program 
	 * 		1) Establishes a connection with the csctrain database*/
	public static void main(String[] args) {
		System.out.println("Hello Eclipse with SVN control!");
		
		Connection myConn = null;
		Statement myStat = null;
		
		try {
			DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
			
			myConn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:csctrain",
					"infodba",
					"infodba");

			if(myConn==null){System.out.println("No Connection");}
			else{System.out.println("Successfully connected to the db!");}
			
			myStat = myConn.createStatement();
			
		} catch (SQLException e) {
			System.out.println("Error opening connection to db");
			e.printStackTrace();
		}
		
		finally{
			try{
				if(myStat!=null){
					myStat.close();
					System.out.println("Connection Closed");
				}
				if(myConn!=null){
					myConn.close();
					System.out.println("Connection Closed");
				}
			}catch(SQLException e){
				System.out.println("Error closing connection to db");
			}
		}
		
	}

}
